package inventory.attribute.dataObjects
{
	import mx.collections.ArrayCollection;
	import common.utils.DateManager;
	
	[Bindable]
	public class AttributeDO
	{
		public var ATTRIBUTE_NUM:int = 0;
		public var ITEM:String = "";
		public var COMPANY:String = "";
		public var ATTRIBUTE1:String = "";
		public var ATTRIBUTE2:String = "";
		public var ATTRIBUTE3:String = "";
		public var ATTRIBUTE4:String = "";
		public var ATTRIBUTE5:String = "";
		public var ATTRIBUTE6:String = "";
		public var ATTRIBUTE7:String = "";
		public var ATTRIBUTE8:String = "";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();

		public function AttributeDO()
		{
		}

		public function Init(xmlObj:XML):void{		
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}
		}
		
		public function ToXML():XML{
			var xmlObj:XML = 
				<ATTRIBUTE>
					<ATTRIBUTE_NUM>{ATTRIBUTE_NUM}</ATTRIBUTE_NUM>
					<ITEM>{ITEM}</ITEM>
					<COMPANY>{COMPANY}</COMPANY>
					<ATTRIBUTE1>{ATTRIBUTE1}</ATTRIBUTE1>
					<ATTRIBUTE2>{ATTRIBUTE2}</ATTRIBUTE2>
					<ATTRIBUTE3>{ATTRIBUTE3}</ATTRIBUTE3>
					<ATTRIBUTE4>{ATTRIBUTE4}</ATTRIBUTE4>
					<ATTRIBUTE5>{ATTRIBUTE5}</ATTRIBUTE5>
					<ATTRIBUTE6>{ATTRIBUTE6}</ATTRIBUTE6>
					<ATTRIBUTE7>{ATTRIBUTE7}</ATTRIBUTE7>
					<ATTRIBUTE8>{ATTRIBUTE8}</ATTRIBUTE8>
					<USER_STAMP>{USER_STAMP}</USER_STAMP>
					<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
				</ATTRIBUTE>;
			return xmlObj;
		}

		public static function getAttributes(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var attrDO:AttributeDO = new AttributeDO();
				attrDO.Init(xml);
				ac.addItem(attrDO);
			}
			return ac;
		}			
	}
}